import com.google.common.eventbus.Subscribe;
import lombok.Data;

import java.util.Objects;

/**
 * Created on 2020/3/24
 * Title: 咕泡学院老师
 * Description: 咕泡学院老师，在观察者模式中，属于观察者
 * Copyright: Copyright(c) 2020
 * Company:
 *
 * @author yifeng
 */
@Data
public class Teacher {

    /**
     * 老师姓名
     */
    private String name;

    public Teacher(String name) {
        Objects.requireNonNull(name);
        this.name = name;
    }

    /**
     * 订阅响应类，一旦订阅的主体发出消息，会调用该方法
     */
    @Subscribe
    public void answer(Question question) {
        System.out.println(name + "老师收到" + question.getQuizzerName() + "同学的问题: " + question.getContent());
    }
}
